/*
 * MoveSupport.h
 *
 *  Created on: 2010-9-12
 *      Author: try
 */

#ifndef MOVESUPPORT_H_
#define MOVESUPPORT_H_

#include "ddatatypes.h"

namespace Ed {

  class MoveSupport {
    public:
      MoveSupport(): refPointX(0), refPointY(0), preparingTransform(false){

      }
      virtual ~MoveSupport(){

      }

      /**
       * 准备变换参照点，x,y 为参照点坐标，一般是在keyPressEvent事件中调用此方法, 参数是当前鼠标x,y坐标
       */
      virtual inline void prepareTransform(real x, real y){
        refPointX = x;
        refPointY = y;
        preparingTransform = true;
      }

      /**
       * 返回参照点X坐标
       */
      virtual inline real referencePointX(){
        return refPointX;
      }

      /**
       * 返回参照点Y坐标
       */
      virtual inline real referencePointY(){
        return refPointY;
      }

      /**
       * 检查是否已经准备好了参照点
       */
      virtual inline bool isPreparingTransform(){
        return preparingTransform;
      }

      /**
       * 结束变换
       */
      virtual inline void endTransform(){
        preparingTransform = false;;
      }

      /**
       * 移动到目标坐标
       */
      virtual inline void moveTo(real x, real y){
        moveBy(x-refPointX, y-refPointY);
        refPointX = x;
        refPointY = y;
      }

      /**
       * 增量移动
       */
      virtual inline void moveBy(real dx, real dy){};

    protected:
      //移动参照点
      real refPointX, refPointY;
      //准备移动标记
      bool preparingTransform;

  };

}

#endif /* MOVESUPPORT_H_ */
